home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / answrbok / 7_10.lha / 7_10 / p_wakeup.c < prev    next >
Text File  |  1993-08-08  |  1KB  |  41 lines

  1. * Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */
  2. * The C++ Answer Book */
  3. * Tony Hansen */
  4. * All rights reserved. */
  5. include <process.h>
  6. include <debug.h>    /* DELETE */
  7. / Wake up the given process by
  8. / moving it to the run list,
  9. / possibly with a time offset.
  10. oid process::wakeup(unsigned long t)
  11.  
  12.    if (debug) /*DELETE*/ cerr << "process" << this << "::wakeup(" << t << ")\n";
  13.    if (debug) /*DELETE*/ cerr << "\tt_curtime == " << t_curtime << "\n";
  14.    switch (t_curstate)
  15. {
  16. case TASK_TERMINATED:
  17.     error("trying to wakeup terminated process");
  18.     return;
  19.  
  20. case TASK_IDLE:
  21.     rmfromlist(this, &t_waitprocesses);
  22.     break;
  23.  
  24. case TASK_CURRENT:
  25.     break;
  26.  
  27. case TASK_RUNNABLE:
  28.     rmfromlist(this, &t_runprocesses);
  29.     break;
  30. }
  31.  
  32.    t_desiredtime = t ? t_curtime + t : 0;
  33.    t_curstate = TASK_RUNNABLE;
  34.    if (debug) /*DELETE*/ cerr << "\tt_desiredtime <- " << t_desiredtime << "\n";
  35.    t_next = t_runprocesses;
  36.    t_runprocesses = this;
  37.    shufflerunlist();
  38.    if (debug) /*DELETE*/ cerr << "<<<< process" << this << "::wakeup(" << t << ")\n";
  39.  
  40.  
  41.